package Classes.GameViews.ViewIcons// ActionScript file
{
	import Classes.GameDatas.GD_BuildingItem;
	import Classes.Interfaces.I_Observer;
	import Classes.Managers.M_ConfigData;

	public class VI_BuildingItem extends ViewIcon implements I_Observer
	{
		private var _buildingItem:GD_BuildingItem
		public function VI_BuildingItem(buildingItem:GD_BuildingItem):void
		{
			super(buildingItem.itemPicSourceStr,buildingItem.itemPicStr);
			this._buildingItem=buildingItem;
			this.init();
		}
		
		private function init():void
		{
			this.showNum();
			this.buildingItem.addObserver("buildingItemNumber",this);
		}
		
		public function touchObserve(observeType:String):void
		{
			switch(observeType)
			{
				case "buildingItemNumber":
					this.showNum();
					break;
			}
		}
		
		private function showNum():void
		{
			this.setNum(this.buildingItem.buildingItemNum);
		}
		
		public function cleanAllObserves():void
		{
			this.buildingItem.removeObserver("itemNumber",this);
		}
		
		override public function release():void
		{
			super.release();
			this.cleanAllObserves();
			this._buildingItem=null;
		}
		
		/*getter & setter*/
		public function get buildingItem():GD_BuildingItem
		{
			return _buildingItem;
		}
		
		override public function get sourcePath():String
		{
			return M_ConfigData.instance.imgUrl+this.sourceName;
		}
	}
}